﻿@model SILAS.Entidades.Ruta

@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_layoutGeneral.cshtml";
}


<script type="text/javascript">

    $(function () {

        $("#btnGuardar").click(function () {

            var data = $('form').serialize();

            $.post('@Url.Action("Edit", "Ruta")',
                         data,
                         function (ok) {
                             if (ok) {
                                 if (ok.exito == true) {
                                     alert(ok.msg);
                                     window.location = '@Url.Action("ListarRutas", "Ruta")';
                                 }
                                 else {
                                     alert(ok.msg);
                                 }
                             }
                         }, "json");
        });

    });


    </script>


<h2>Editar Ruta</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Ruta</legend>

        @Html.HiddenFor(model => model.Id)

        <div class="editor-label">
            @Html.LabelFor(model => model.Desde)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Desde)
            @Html.ValidationMessageFor(model => model.Desde)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Hasta)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Hasta)
            @Html.ValidationMessageFor(model => model.Hasta)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Distancia)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Distancia)
            @Html.ValidationMessageFor(model => model.Distancia)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Tiempo)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Tiempo)
            @Html.ValidationMessageFor(model => model.Tiempo)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.IdTipoVia)
        </div>
        <div class="editor-field">
            @Html.DropDownList("IdTipoVia")
            @Html.ValidationMessageFor(model => model.IdTipoVia)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.IdMedioTransp)
        </div>
        <div class="editor-field">
           @Html.DropDownList("IdMedioTransp")
            @Html.ValidationMessageFor(model => model.IdMedioTransp)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.IdSector)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.IdSector)
            @Html.ValidationMessageFor(model => model.IdSector)
        </div>

        <p style='clear:both;margin-top:10em;padding:1em;'>
            <button id="btnGuardar" type="button">Guardar Cambios</button> 
            
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Regresar a Listar", "ListarRutas")
</div>

